package xian.woniuxy.a_oop.liskov;

class Rectangle {
    private int length, width;

    public Rectangle(int length, int width) {
        this.length = length;
        this.width = width;
    }

    public int getLength() {
        return length;
    }

    public void setLength(int length) {
        this.length = length;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    // 业务
    public void transform() {
        while (getWidth() <= getLength()) {
            setWidth(getWidth() + 1);
            System.out.println(getWidth() + " : " + getLength());
        }
    }
}

class Square extends Rectangle {
    private int sideLength;
    public Square(int sideLength) {
        super(sideLength, sideLength);
    }

    @Override
    public void setLength(int length) {
        sideLength = length;
    }

    @Override
    public void setWidth(int width) {
        sideLength = width;
    }

    @Override
    public int getLength() {
        return sideLength;
    }
    @Override
    public int getWidth() {
        return sideLength;
    }
}

public class App {
    public static void main(String[] args) {
        Rectangle r = new Square(20);
        r.transform();
    }
}
